package com.tedu.egmybatis1.mapper;

import com.tedu.egmybatis1.pojo.Product;
import org.apache.ibatis.annotations.*;

import java.util.List;


@Mapper
public interface ProductMapper {

    @Insert("INSERT INTO product(title,price,stock) " +
            "VALUES (#{title},#{price},#{stock}) ")
    int insert(Product  product);

    @Update("UPDATE product " +
            "SET title=#{title},price=#{price},stock=#{stock} "+
            "WHERE id=#{id}")
    int updataProductById(Integer id);


    @Select("SELECT title,price,stock " +
            "FROM product " +
            "WHERE id=#{id} ")
    Product selectSingleProduct(Integer id);

    @Delete("DELETE FROM product " +
            "WHERE id=#{id}")
    int deleteproductById(Integer id);

    @Select("SELECT * FROM product")
    List<Product> selectAllProducts();
}
